package cn.iocoder.yudao.module.famous.doctor.controller.app.banner;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.famous.doctor.controller.admin.banner.vo.*;
import cn.iocoder.yudao.module.famous.doctor.convert.banner.FamBannerConvert;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.banner.FamBannerDO;
import cn.iocoder.yudao.module.famous.doctor.service.banner.FamBannerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 名医-轮播图")
@RestController
@RequestMapping("/famous.doctor/fam-banner")
@Validated
public class AppFamBannerController {

    @Resource
    private FamBannerService famBannerService;

    @GetMapping("/getInfo")
    @Operation(summary = "获得名医-轮播图")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<FamBannerRespVO> getFamBannerInfo(@RequestParam("id") Long id) {
        FamBannerDO famBanner = famBannerService.getFamBanner(id);
        return success(FamBannerConvert.INSTANCE.convert(famBanner));
    }

    @GetMapping("/listAll")
    @Operation(summary = "获得名医-轮播图列表")
    @Parameter(name = "deviceType", description = "类型1用户2医生 不填默认用户", required = true, example = "1024")
    public CommonResult<List<FamBannerRespVO>> listAll(@RequestParam(value = "deviceType",required = false) Integer deviceType) {
        List<FamBannerDO> list = famBannerService.getFamBannerList(deviceType);
        return success(FamBannerConvert.INSTANCE.convertList(list));
    }

}
